import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/views/layout/Layout'

Vue.use(Router)

export const constantRouterMap = [
  {
    path: '',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index'),
      meta: {title: '首页', icon: 'home'}
    }]
  },
  {
    path: '/template',
    component: Layout,
    meta: {title: '我的模板', icon: 'product-attr' },
    children: [{
      path: 'template',
      name: 'templateConfigList',
      component: () => import('@/views/templateConfig/index'),
      meta: {title: '模板列表', icon: 'product-attr' },
    },{
      path: 'templateField',
      name: 'templateFieldConfigList',
      component: () => import('@/views/templateFieldConfig/index'),
      meta: {title: '模板控件', icon: 'product-attr' },
    }]
  },
  {
    path: '/datasource',
    component: Layout,
    meta: {title: '数据源', icon: 'product-attr' },
    children: [{
      path: 'database',
      name: 'projectDatasourceList',
      component: () => import('@/views/projectDatasource/index'),
      meta: {title: '数据库', icon: 'product-attr' },
    },{
      path: 'tableField',
      name: 'tableFieldList',
      component: () => import('@/views/tableConfig/index'),
      meta: {title: '数据表', icon: 'product-attr' },
    }]
  }, {
    path: '/project',
    component: Layout,
    meta: {title: '项目管理', icon: 'product-attr'},
    children: [{
      path: 'project',
      name: 'projectList',
      component: () => import('@/views/project/index'),
      meta: {title: '项目列表', icon: 'product-attr'},
    }, {
      path: 'tableFieldConfig',
      name: 'projectTableFiledConfigList',
      component: () => import('@/views/projectTableFiledConfig/index'),
      meta: {title: '字段映射', icon: 'product-attr'},
    }, {
      path: 'pageConfig',
      name: 'projectTablePageConfigList',
      component: () => import('@/views/projectTablePageConfig/index'),
      meta: {title: '页面配置', icon: 'product-attr'},
    }, {
      path: 'createCode',
      name: 'tableToCode',
        component: () => import('@/views/tableToCode/index'),
      meta: {title: '表转代码', icon: 'product-attr'},
    }]
  },
  {
    path: '/tableFieldConfigPre',
    component: Layout,
    meta: {title: '字段映射字典', icon: 'product-attr' },
    children: [{
      path: 'tableFieldConfigPre',
      name: 'projectTableFiledConfigPreList',
      component: () => import('@/views/projectTableFiledConfigPre/index'),
      meta: {title: '字段映射字典', icon: 'product-attr' },
    }]
  },
  {
    path: '/tool',
    component: Layout,
    meta: {title: '模板代码预览', icon: 'product-attr'},
    children: [{
      path: 'codePreviewView',
      name: 'codePreviewView',
      component: () => import('@/views/generationTools/index'),
      meta: {title: '模板代码预览', icon: 'product-attr'},
    }]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})